﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        string str;

        public Form1()
        {
            InitializeComponent();
            str = "";
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            //具体哪个字符被输入
            char c = e.KeyChar;

            if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'z'))//字母
            {
                if (checkBox1.Checked == true) str += c;
            }
            else if (c >= '0' && c <= '9')//数字
            {
                if (checkBox2.Checked == true) str += c;
            }
            else//其它字符
            {
                if (checkBox3.Checked == true) str += c;
            }
        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            //具体哪个按键被按下
            int n = e.KeyValue;
        }

        private void textBox1_KeyUp(object sender, KeyEventArgs e)
        {
            textBox1.Text = str;
            textBox1.Select(textBox1.Text.Length, 0);//把光标置于最后
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
                textBox2.Text = textBox1.Text.ToUpper();
            
            else if (radioButton2.Checked == true)
                textBox2.Text = textBox1.Text.ToLower();
        }
    }
}
